package com.sinosoft.sm.message.web.dto;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.sinosoft.sm.message.entity.MessageRecordEntity;
import com.sinosoft.sm.system.common.SystemContants;
import com.sinosoft.sm.system.common.utils.ObjectUtil;

public class RecordData implements Serializable{

	private static final long serialVersionUID = 1L;
	
	private String id;  //id
	
	private String username;  //发送者标识
	
	private String name;
	
	private String state;  //发送状态    0:失败    1：成功
	
	private String receiver;  //接收者联系电话
	
	private Date sendtime;
	
	private String sendTimeStr;
	
	private String message;
	
	private String explain;
	
	private String begintime;
	
	private String endtime;

	private int page;	//	当前页
	    
	private int rows;	//	数据大小
		
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Date getSendtime() {
		return sendtime;
	}

	public void setSendtime(Date sendtime) {
		this.sendtime = sendtime;
		SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd");
		setSendTimeStr(s.format(sendtime));
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		if(SystemContants.SEND_MESSAGE_SUCCESS.equals(state)){
			this.state = "发送成功";
		}else if(SystemContants.SEND_MESSAGE_FAILURE.equals(state)){
			this.state = "发送失败";
		}else{
			this.state = state;
		}
	}
	
	public String getExplain() {
		return explain;
	}

	public void setExplain(String explain) {
		this.explain = explain;
	}

	public String getReceiver() {
		return receiver;
	}

	public void setReceiver(String receiver) {
		this.receiver = receiver;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getBegintime() {
		return begintime;
	}

	public void setBegintime(String begintime) {
		this.begintime = begintime;
	}

	public String getEndtime() {
		return endtime;
	}

	public void setEndtime(String endtime) {
		this.endtime = endtime;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getRows() {
		return rows;
	}

	public void setRows(int rows) {
		this.rows = rows;
	}
	
	public String getSendTimeStr() {
		return sendTimeStr;
	}

	public void setSendTimeStr(String sendTimeStr) {
		this.sendTimeStr = sendTimeStr;
	}

	/**
	 * 数据转换
	 * 实体类转传输类
	 * @param userEntity	用户实体数据
	 */
	public void toRecordData(MessageRecordEntity userEntity) {
		ObjectUtil.oldToNew(this, userEntity, "serialVersionUID");
	}
	
	/**
	 * 数据转换
	 * 传输类转实体类
	 * @return	用户实体数据
	 */
	public MessageRecordEntity toMessageRecordEntity() {
		MessageRecordEntity messageRecordEntity = new MessageRecordEntity();
		ObjectUtil.oldToNew(messageRecordEntity, this, "serialVersionUID");
		return messageRecordEntity;
	}
}
